home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / drgnsmth.cpt / Dragonsmith 1.1 / Base files / Utilities / FileUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-13  |  3.0 KB  |  83 lines

  1. /*
  2.     FileUtils.h
  3. */
  4.  
  5. #pragma once
  6.  
  7. #include    <Files.h>
  8. #include    <Aliases.h>
  9. #include    <Folders.h>
  10.  
  11. #define    kInvalidRefNum    -1
  12.  
  13. enum {
  14.         kInvalidFork,
  15.         kResFork,
  16.         kDataFork,
  17.         kBothForks
  18. };
  19.  
  20. typedef union {
  21.     ParamBlockRec    p;
  22.     HParamBlockRec    h;
  23.     CInfoPBRec        c;
  24.     CMovePBRec        cmove;
  25.     WDPBRec        wd;
  26.     FCBPBRec        fcb;
  27. } PBRecUnion;
  28.  
  29. // Tired of twisting and turning through unions and structs in the param block? ╤ use these macros
  30. // Remember ╤ garbage in, garbage out ╤ so use them with discretion, only after calling one of the PB routines
  31. //    that return valid data, and only after checking for an error
  32. // The numbers given in the comments on the right are the offsets to the pertinent fields
  33.  
  34. // Macros that are valid ONLY for CInfoPBRec's and must follow a call to PBGetCatInfo ╤
  35.  
  36.     #define    PBParID(pb)            (((CInfoPBRec *) pb)->hFileInfo.ioFlParID)                        // 100
  37.     #define    PBIsVolume(pb)        (((CInfoPBRec *) pb)->hFileInfo.ioFlParID == fsRtParID)            // 100
  38.     #define    PBIsAliasFile(pb)        (!(((HParmBlkPtr) pb)->fileParam.ioFlAttrib & ioDirMask) \
  39.                                 && (((CInfoPBRec *) pb)->hFileInfo.ioFlFndrInfo.fdFlags & 0x8000))    // 30, 32 + 8
  40.  
  41. // Valid for CInfoPBRec's and HParamBlockRec's ╤
  42.  
  43.     // Must follow a call to PBGetCatInfo or PB(H)GetFileInfo ╤
  44.     
  45.         // Valid for files and directories ╤
  46.         
  47.             #define    PBCreated(pb)        (((HParmBlkPtr) pb)->fileParam.ioFlCrDat)                // 72
  48.             #define    PBModified(pb)        (((HParmBlkPtr) pb)->fileParam.ioFlMdDat)                // 76
  49.             #define    PBIsDirectory(pb)        (((HParmBlkPtr) pb)->fileParam.ioFlAttrib & ioDirMask)        // 30
  50.             #define    PBIsFile(pb)            !(((HParmBlkPtr) pb)->fileParam.ioFlAttrib & ioDirMask)    // 30
  51.         
  52.         // Valid only for files ╤
  53.         
  54.             #define    PBFileType(pb)        (((HParmBlkPtr) pb)->fileParam.ioFlFndrInfo.fdType)        // 32 + 0
  55.             #define    PBFileCreator(pb)        (((HParmBlkPtr) pb)->fileParam.ioFlFndrInfo.fdCreator)    // 32 + 4
  56.             #define    PBFileFlags(pb)        (((HParmBlkPtr) pb)->fileParam.ioFlFndrInfo.fdFlags)        // 32 + 8
  57.             #define    PBDataForkSize(pb)    (((HParmBlkPtr) pb)->fileParam.ioFlLgLen)                // 54
  58.             #define    PBResForkSize(pb)    (((HParmBlkPtr) pb)->fileParam.ioFlRLgLen)                // 64
  59.  
  60.     // Do not need to follow PBGetCatInfo or PB(H)GetFileInfo ╤
  61.     
  62.         #define    PBVolRefNum(pb)        (((HParmBlkPtr) pb)->fileParam.ioVRefNum)                    // 22
  63.         #define    PBName(pb)            (((HParmBlkPtr) pb)->fileParam.ioNamePtr)                    // 18
  64.  
  65. typedef struct {
  66.     short    numTypes;
  67.     OSType    type[];
  68. } *TypeListPtr, **TypeListHndl;
  69.  
  70. void FSpRefreshFinderDisplay (FSSpec *fss);
  71.  
  72. OSErr FSpOpenDataFork (FSSpec *fss, short *refNum, char *perm);
  73. OSErr FSpOpenResFork (FSSpec *fss, short *refNum, char *perm);
  74.  
  75. OSErr FSpFindFolder (OSType folderType, FSSpec *fss);
  76.  
  77. OSErr FSpToPB (PBRecUnion *pb, FSSpec *fss, Boolean resolveAFs, Boolean followAFChain, Boolean *wasAF);
  78. OSErr FSpToPBCatInfo (PBRecUnion *pb, FSSpec *fss, Boolean resolveAFs, Boolean followAFChain, Boolean *wasAF);
  79. OSErr PBToFSpCatInfo (PBRecUnion *pb, FSSpec *fss, Boolean resolveAFs, Boolean followAFChain, Boolean *wasAF);
  80.  
  81. TypeListHndl FREFTypes (short resFork);
  82. Boolean OpenableType (OSType fileType, TypeListHndl openableTypesHndl);
  83. OSErr RefNumToFSSpec (short refNum, FSSpec *fss, Boolean *isResFork);